import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_navigation/get_navigation.dart';
import 'package:xiongmao_clean_flutter_module/business/common/insure/page/Insure_details_page.dart';
import 'package:xiongmao_clean_flutter_module/business/common/web/page/web_page.dart';
import 'package:xiongmao_clean_flutter_module/res/gaps.dart';

import '../bean/custom_Insure_history_entity.dart';

class InsureHistoryListView extends StatefulWidget {
  @override
  _InsureHistoryListViewState createState() => _InsureHistoryListViewState();
}

class _InsureHistoryListViewState extends State<InsureHistoryListView> {
  final List<CustomInsureHistoryEntity> dataList = [
    CustomInsureHistoryEntity(name: '中国平安保险', payDate: "2024-08-15购买", noNumber: "24187284913891934124", product: "商业清洁雇主责任险-标准版", productDate: "2024.10.28至2025.11.27", personnel: "王星星(在职)"),
    CustomInsureHistoryEntity(name: '中国人保保险', payDate: "2024-09-15购买", noNumber: "34020385498543985344", product: "商业清洁雇主责任险-高级版", productDate: "2024.10.28至2025.11.27", personnel: "王跃正(在职)"),
    CustomInsureHistoryEntity(name: '中国大地保险', payDate: "2024-09-05购买", noNumber: "23128741783643414134", product: "商业清洁雇主责任险-尊享版", productDate: "2024.10.28至2025.11.27", personnel: "王跃正(在职)"),
  ];

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      padding: EdgeInsets.only(top: 10), // 设置padding为零
      shrinkWrap: true,
      itemCount: dataList.length,
      itemBuilder: (context, position) {
        return GestureDetector(
          onTap: () {
            //在这里跳转详情
            Get.to(InsureDetailsPage());
          },
          child: Container(
            margin: EdgeInsets.only(right: 16, left: 16, bottom: 10),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(10.0), // 设置圆角半径为10.0
              color: Colors.white, // 设置背景颜色为灰色
            ),
            padding: EdgeInsets.all(16.0), // 设置内边距为16.0
            child: Column(
              children: [
                Row(
                  children: [
                    Expanded(child: Text(dataList[position].name)),
                    Expanded(
                      child: Text(
                        dataList[position].payDate,
                        textAlign: TextAlign.right, // 设置文本右对齐
                      ),
                    ),
                  ],
                ),
                Gaps.vGap4,
                Gaps.line,
                Gaps.vGap4,
                //保单号
                Row(
                  children: [
                    Text(
                      "保单号",
                      style: TextStyle(fontSize: 12, color: Colors.black),
                    ),
                    Expanded(
                      child: Text(
                        dataList[position].noNumber,
                        textAlign: TextAlign.right, // 设置文本右对齐
                        style: TextStyle(fontSize: 12, color: Colors.grey),
                      ),
                    ),
                  ],
                ),
                Gaps.vGap2,
                //购买产品
                Row(
                  children: [
                    Text(
                      "购买产品",
                      style: TextStyle(fontSize: 12, color: Colors.black),
                    ),
                    Expanded(
                      child: Text(
                        dataList[position].product,
                        textAlign: TextAlign.right, // 设置文本右对齐
                        style: TextStyle(fontSize: 12, color: Colors.grey),
                      ),
                    ),
                  ],
                ),
                Gaps.vGap2,
                //保险期
                Row(
                  children: [
                    Text(
                      "保险期",
                      style: TextStyle(fontSize: 12, color: Colors.black),
                    ),
                    Expanded(
                      child: Text(
                        dataList[position].productDate,
                        textAlign: TextAlign.right, // 设置文本右对齐
                        style: TextStyle(fontSize: 12, color: Colors.grey),
                      ),
                    ),
                  ],
                ),
                Gaps.vGap4,
                Gaps.line,
                Gaps.vGap4,
                //在保人员
                Row(
                  children: [
                    Text(
                      "在保人员",
                      style: TextStyle(fontSize: 12, color: Colors.black),
                    ),
                    Expanded(
                      child: Text(
                        dataList[position].personnel,
                        textAlign: TextAlign.right, // 设置文本右对齐
                        style: TextStyle(fontSize: 12, color: Colors.grey),
                      ),
                    ),
                  ],
                ),
                Gaps.vGap8,
                //底部按钮操作
                Row(
                  children: [
                    Expanded(
                      child: GestureDetector(
                        onTap: () {
                          // 处理点击事件
                          Get.to(WebPage());
                        },
                        child: const Text(
                          '电子保单',
                          textAlign: TextAlign.left,
                          style: TextStyle(
                            color: Colors.green,
                            fontSize: 12,
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: GestureDetector(
                        onTap: () {
                          Get.to(WebPage());
                        },
                        child: const Text(
                          '电子发票',
                          textAlign: TextAlign.center,
                          style: TextStyle(
                            color: Colors.green,
                            fontSize: 12,
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: GestureDetector(
                        onTap: () {
                          Get.to(WebPage());
                        },
                        child: const Text(
                          '申请理赔',
                          textAlign: TextAlign.right,
                          style: TextStyle(
                            color: Colors.green,
                            fontSize: 12,
                          ),
                        ),
                      ),
                    ),
                  ],
                )
              ],
            ),
          ),
        );
      },
    );
  }
}
